<div class="page-center">
  <div class="main-page">
    <div class=" grid_12 t_space_bottom" id="container_1">
      <div class="breadcrumb"><a href="<?php echo base_url(); ?>">Home</a> <span>&gt;</span> <b>Find ticket</b> </div>
    </div>
    <div class=" grid_12 t_space_bottom" id="container_2">
      <div class=" grid_3 omega col-left-243" id="container_3"> 
      <?php $this->load->view("public/formrate"); ?>  
      </div>
      <div class=" grid_9 alpha col-696 Fr" id="container_4">
        <style>
			#date_19 + img, #date_20 + img {left: -2px;position: relative;top: 5px;	}
			#btnsearch{float:none; margin-top:0px;padding:1px 6px; }
			.tab-child {width:626px !important;}
			.tab-child ul li a {padding:0 33px 0 35px;} 
			.tab-small {padding-top:10px;}
			.tab-small p{padding:5px 0px;}
		</style>
        <div> <img id="loading-icon" src="<?php echo base_url(); ?>public/images/preloader_transparent.gif" style="position:fixed;left:50%;top:40%;display:none;"/>
          <script type="text/javascript">
		  $(document).ready(function(){
			  $(document).on("click","#btnsearch",function(){
				  $depart = $("#tickstart").val();
				  $return = $("#tickend").val();
				  $typetick = $("#tickty").val();
				  $trainid = $("#train_id").val();
				  $icons = $("#loading-icon"); $icons.show();
				  $adults = $("#adults").val();
				  if($("#train_id").val() == 0){ alert("Please select a train"); return false;}
				  if(document.getElementById("roundtrip").checked){
					 if($return == ""){ alert("Please select return date");$("#tickend").focus(); return false;}
					 if($depart > $return){alert("Return date must be greater than depart"); return false;}
				  }
				  jQuery.post("<?php echo base_url()."home/checkrate/ajax"; ?>",{trainid:$trainid,type:$typetick,depart:$depart,returns:$return,adults:$adults},function(result){
					  $icons.hide();
					  $("#result").html(result).find(".hadate").datepicker({ minDate: 0, dateFormat: "mm/dd/yy"});
				  });
			  });
			  $(document).on("click",".radprice",function(){
				  $val = $(this).val();$trainame = $("#trainname").val();
				  $type = $(this).attr("datatype");$number = $("#adults").val();
				  $id  = $(this).attr("dataid");$depart = $("#tickstart").val();
				  $name = $(this).attr("dataname");$return = $("#tickend").val();
				  $from = $(this).attr("datafrom"); $to = $(this).attr("datato");
				  //alert($trainame); return false;
				  jQuery.post("<?php echo base_url()."home/cart/add"; ?>",{id:$id,type:$type,val:$val,name:$name,depart:$depart,returns:$return,number:$number,trainame:$trainame,from:$from,to:$to},function(result){
					  $("#lblPrice").html("$"+result);
					  $("#btnContinue").removeClass("none");
				  });
			  });
		  });
		  </script>
          <div class="clearfix box-schedule">
            <div class="line10 overflow" style="padding:15px 25px;">HANOI SAPA TRAIN ON
              <select id="train_id">
                <option value="0">Choose one train</option>
                <?php if(isset($trains)){ foreach($trains as $train){ ?>
                <option value="<?php echo $train['train_id']; ?>" <?php if($train['train_id'] == $trainid){ echo "selected='selected'";} ?>><?php echo $train['train_name']; ?></option>
                <?php } } ?>
              </select>
              <button type="button" id="btnsearch" class="">Search</button>
            </div>
            <form id="frmContinue" name="frmContinue" action="#" method="post">
              <div id="result">
                <div class="clearfix box-schedule" id="divAjax">
                  <input type="hidden" name="train_id" value="18"/>
                  <input type="hidden" id="tickty" value="<?php echo $typetick; ?>"/>
                  <p class="line25"> <b>Hanoi - Sapa on <?php echo $curtrain['train_name']; ?></b> </p>
                  <p class="line12"> Departing:
                    <input type="hidden" id="trainname" value="<?php echo $curtrain['train_name']; ?>" />
                    <input type="text" value="<?php echo $curstart; ?>" id="tickstart" class="input-text hadate" readonly="readonly">
                  </p>
                  <p class="numPeople line">
					<label id="lbAdult">Number of passengers : <?php echo $adults; ?></label>
				  </p>
                  <table class="tableStyle">
                    <tr>
                      <th>Departs</th>
                      <th>Arrives</th>
                      <th>Duration</th>
                      <th>Train</th>
                      <th>Soft Seat</th>
                      <th>Hard Berth</th>
                      <th>Soft berth</th>
                      <th>Vip Berth</th>
                    </tr>
                    <?php if(isset($liststart) && $liststart != NULL){ ?>
                    <?php foreach($liststart as $tickstart){ ?>
                    <tr>
                      <td><?php echo $tickstart['tickdeparts']; ?></td>
                      <td><?php echo $tickstart['tickarrives']; ?></td>
                      <td><?php echo $tickstart['tickduration']; ?></td>
                      <td><a title="" target="_blank">SP3</a></td>
                      <td><?php if($tickstart['softseat'] != 0){ echo "<span><input class='radprice' datatype='1' datafrom='Hanoi' datato='Sapa' dataname='Soft Seat' dataid='".$tickstart['tickid']."' value='".$tickstart['softseat']."' name='rooms".$tickstart['tickid']."' type='radio' />&nbsp;$".$tickstart['softseat']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                      <td><?php if($tickstart['hardberth'] != 0){ echo "<span><input class='radprice' datatype='1' datafrom='Hanoi' datato='Sapa' dataname='Hard Berth' dataid='".$tickstart['tickid']."' value='".$tickstart['hardberth']."' name='rooms".$tickstart['tickid']."' type='radio' />&nbsp;$".$tickstart['hardberth']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                      <td><?php if($tickstart['softberth'] != 0){ echo "<span><input class='radprice' datatype='1' datafrom='Hanoi' datato='Sapa' dataname='Soft berth' dataid='".$tickstart['tickid']."' value='".$tickstart['softberth']."' name='rooms".$tickstart['tickid']."' type='radio' />&nbsp;$".$tickstart['softberth']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                      <td><?php if($tickstart['vipberth'] != 0){ echo "<span><input class='radprice' datatype='1' datafrom='Hanoi' datato='Sapa' dataname='Vip Berth' dataid='".$tickstart['tickid']."' value='".$tickstart['vipberth']."' name='rooms".$tickstart['tickid']."' type='radio' />&nbsp;$".$tickstart['vipberth']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                    </tr>
                    <?php } }else{ ?>
                    <tr>
                      <th colspan="8" style="background:none;color:#000">No tickets available</th>
                    </tr>
                    <?php } ?>
                  </table>
                  <p class="line25"> <b>Sapa - Hanoi on <?php echo $curtrain['train_name']; ?></b> </p>
                  <p class="line12"> Return:
                    <input type="text" value="<?php echo $curendate; ?>" id="tickend" class="input-text hadate" readonly="readonly" />
                  </p>
                  <p class="numPeople line">
					<label id="lbAdult">Number of passengers : <?php echo $adults; ?></label>
				  </p>
                  <table class="tableStyle">
                    <tr>
                      <th>Departs</th>
                      <th>Arrives</th>
                      <th>Duration</th>
                      <th>Train</th>
                      <th>Soft Seat</th>
                      <th>Hard Berth</th>
                      <th>Soft berth</th>
                      <th>Vip Berth</th>
                    </tr>
                    <?php if(isset($listend) && $listend != NULL){ ?>
                    <?php foreach($listend as $tickend){ ?>
                    <tr>
                      <td><?php echo $tickend['tickdeparts']; ?></td>
                      <td><?php echo $tickend['tickarrives']; ?></td>
                      <td><?php echo $tickend['tickduration']; ?></td>
                      <td><a title="" target="_blank">SP3</a></td>
                      <td><?php if($tickend['softseat'] != 0){ echo "<span><input class='radprice' datatype='2' datafrom='Sapa' datato='Hanoi' dataname='Soft Seat' dataid='".$tickend['tickid']."' value='".$tickend['softseat']."' name='rooms".$tickend['tickid']."' type='radio' />&nbsp;$".$tickend['softseat']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                      <td><?php if($tickend['hardberth'] != 0){ echo "<span><input class='radprice' datatype='2' datafrom='Sapa' datato='Hanoi' dataname='Hard Berth' dataid='".$tickend['tickid']."' value='".$tickend['hardberth']."' name='rooms".$tickend['tickid']."' type='radio' />&nbsp;$".$tickend['hardberth']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                      <td><?php if($tickend['softberth'] != 0){ echo "<span><input class='radprice' datatype='2' datafrom='Sapa' datato='Hanoi' dataname='Soft berth' dataid='".$tickend['tickid']."' value='".$tickend['softberth']."' name='rooms".$tickend['tickid']."' type='radio' />&nbsp;$".$tickend['softberth']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                      <td><?php if($tickend['vipberth'] != 0){ echo "<span><input class='radprice' datatype='2' datafrom='Sapa' datato='Hanoi' dataname='Vip Berth' dataid='".$tickend['tickid']."' value='".$tickend['vipberth']."' name='rooms".$tickend['tickid']."' type='radio' />&nbsp;$".$tickend['vipberth']."</span>"; }else{ echo "<span>N/A</span>";} ?></td>
                    </tr>
                    <?php } }else{ ?>
                    <tr>
                      <th colspan="8" style="background:none;color:#000">No tickets available</th>
                    </tr>
                    <?php } ?>
                  </table>
                  <div id="ticket-total-bound">
                    <div class="left-ttb" style="float:left">
                      <div class="line num-pass">
                        <h3 class="line6">Number of Passengers</h3>
                        <select class="Fl" id="adults" name="adults">
                          <?php for($i=1;$i<=10;$i++){ ?>
                          <option value="<?php echo $i; ?>" <?php if($adults == $i){ echo "selected='selected'";} ?>><?php echo $i; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                    </div>
                    <div class="right-ttb" style="float:right;">
                      <p align="right" class="lineH16 line"> <b class="size13 line3">Ticket Total:
                        <label id="lblPrice">$ 0</label>
                        </b><br>
                        <span class="c_a0">* This price is exclusive of credit card processing fee (4%)</span> </p>
                    </div>
                  </div>
                  <p class="line12">
                    <a href="<?php echo base_url()."extra-services.html?train=".$curtrain['train_id']; ?>" class="btn btn-red continue none" id="btnContinue"><span>Continue</span></a>
                  </p>
                </div>
                <div class="tab-ticket-bound" >
                  <div class="right-tab-content2222">
                    <div class="tab-child overflow">
                      <ul class="list">
                        <li class="active"><a href="#overiew-routes"><span><b>Overview</b></span></a></li>
                        <li class=""><a href="#overiew-fearture"><span><b>Fearture</b></span></a></li>
                        <li class=""><a href="#overiew-eat-sleep"><span><b>Eat &amp; Sleep</b></span></a></li>
                        <li class=""><a href="#overiew-attractions"><span><b>Attractions</b></span></a></li>
                        <li class=""><a href="#overiew-direction"><span><b>Direction</b></span></a></li>
                      </ul>
                    </div>
                    <div class="clear"></div>
                    <div class="tab-small clearfix" id="overiew-routes" style="display: block;">
                      <p> <strong><?php echo $curtrain['train_name']; ?></strong></p>
                      <p><?php echo $curtrain['train_overview']; ?></p>
                    </div>
                    <div style="display: none;" class="tab-small clearfix" id="overiew-fearture"> </div>
                    <div style="display: none;" class="tab-small clearfix" id="overiew-eat-sleep"> </div>
                    <div style="display: none;" class="tab-small clearfix" id="overiew-attractions"> </div>
                    <div style="display: none;" class="tab-small clearfix" id="overiew-direction"> </div>
                  </div>
                </div>
                </div>
            </form>
          </div>
          <div class="line18" style="margin-top:15px;">
            <div class="gray-gar-block clearfix">
              <h2 class="title-bw size18 lineH26 normal">Best Sellers</h2>
              <div class="line20">
                <ul class="list top-sellers Fl boder-right">
                  <!-- DAU GACH O GIUA UL -->
                  <div id="anti-ul-top-seller"></div>
                  <?php if(isset($listtrains)){ foreach($listtrains as $train){ ?>
                  <?php $fordel = $train['train_folderimg']; ?>
                  <li> <a href="<?php echo base_url()."train/".$train['train_rewrite']; ?>.html"> <img src="<?php echo base_url()."uploads/trains/thumb/".$train['train_image']; ?>" alt="" /> 
                    <!-- <img alt="" src="img/img-66-60.jpg"> --> 
                    </a>
                    <div class="desc">
                      <h3><a href="<?php echo base_url()."train/".$train['train_rewrite']; ?>.html"><?php echo $train['train_name']; ?></a><?php if($train['train_hot'] == 1){ ?>&nbsp; <a class="btn btn-promo" href="javascript:void(0)" rel="nofollow">PROMO</a> <?php } ?></h3>
                      <?php echo $train['train_info']; ?></div>
                  </li>
                  <?php } } ?>
                </ul>
              </div>
            </div>
          </div>
        </div>
        </div>
    </div>
    </div>
</div>
<div class="page-center">
  <div class="signup-offer">
    <div class="signup-banner"> <b class="inline-block size16">Have any questions? Please contact us</b> <a class="button btn-offer" href="<?php echo base_url(); ?>contact.html">Contact</a> <span class="inline-block size11">Don't worry, we won't share your details with anyone alse</span> </div>
  </div>
  <!--/ SIGN UP - OFFER --> 
</div>
